Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-virtuoso
Advanced tools
react-virtuoso is a performant and easy-to-use React component for rendering large lists and tabular data. It provides a virtualized list component that only renders the visible items, significantly improving performance for large datasets.
Basic List
This code demonstrates how to create a basic virtualized list with 1000 items using react-virtuoso. Only the visible items are rendered, improving performance.
```jsx
import React from 'react';
import { Virtuoso } from 'react-virtuoso';
const App = () => (
<Virtuoso
totalCount={1000}
itemContent={index => <div>Item {index}</div>}
/>
);
export default App;
```
Grouped List
This code demonstrates how to create a grouped list using react-virtuoso. The list is divided into groups, and each group and its items are rendered only when they are visible.
```jsx
import React from 'react';
import { Virtuoso } from 'react-virtuoso';
const App = () => (
<Virtuoso
groupCounts={[3, 2, 5]}
groupContent={index => <div>Group {index}</div>}
itemContent={(index, groupIndex) => <div>Item {index} in Group {groupIndex}</div>}
/>
);
export default App;
```
Table
This code demonstrates how to create a virtualized table using react-virtuoso. The table renders only the visible rows, which improves performance when dealing with large datasets.
```jsx
import React from 'react';
import { TableVirtuoso } from 'react-virtuoso';
const App = () => (
<TableVirtuoso
data={Array.from({ length: 1000 }, (_, index) => ({ id: index, name: `Item ${index}` }))}
columns={[{ key: 'id', label: 'ID' }, { key: 'name', label: 'Name' }]}
itemContent={(index, item) => (
<tr>
<td>{item.id}</td>
<td>{item.name}</td>
</tr>
)}
/>
);
export default App;
```
react-window is a lightweight library for rendering large lists and tabular data. It provides similar functionality to react-virtuoso but with a smaller API surface. It is highly performant and easy to use, but may require more manual setup for advanced use cases.
react-virtualized is a comprehensive library for rendering large lists, tables, and grids. It offers a wide range of features and customization options, making it suitable for complex use cases. However, it has a steeper learning curve compared to react-virtuoso.
react-infinite-scroll-component is a simple library for implementing infinite scrolling in React applications. It is less feature-rich compared to react-virtuoso but is easy to set up and use for basic infinite scrolling needs.
React Virtuoso - the most complete React virtualization rendering list/table/grid family of components.
For live examples and documentation, check the documentation website.
If you are using Virtuoso for work, sponsor it. Any donation helps a lot with the project development and maintenance.
npm install react-virtuoso
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { Virtuoso } from 'react-virtuoso'
const App = () => {
return <Virtuoso style={{ height: '400px' }} totalCount={200} itemContent={index => <div>Item {index}</div>} />
}
ReactDOM.render(<App />, document.getElementById('root'))
The Virtuoso message list component is built specifically for human/chatbot conversations. In addition to the virtualized rendering, the component exposes an imperative data management API that gives you the necessary control over the scroll position when older messages are loaded, new messages arrive, and when the user submits a message. The scroll position can update instantly or with a smooth scroll animation.
The GroupedVirtuoso
component is a variant of the "flat" Virtuoso
, with the following differences:
totalCount
, the component exposes groupCounts: number[]
property, which specifies the amount of items in each group.
For example, passing [20, 30]
will render two groups with 20 and 30 items each;itemContent
property, the component requires an additional groupContent
property,
which renders the group header. The groupContent
callback receives the zero-based group index as a parameter.The VirtuosoGrid
component displays same sized items in multiple columns.
The layout and item sizing is controlled through CSS class properties, which allows you to use media queries, min-width, percentage, etc.
The TableVirtuoso
component works just like Virtuoso
, but with HTML tables.
It supports window scrolling, sticky headers, sticky columns, and works with React Table and MUI Table.
You can customize the markup up to your requirements - check the Material UI list demo. If you need to support reordering, check the React Sortable HOC example.
For in-depth documentation and live examples of the supported features and live demos, check the documentation website.
To support legacy browsers, you might have to load a ResizeObserver Polyfill before using react-virtuoso
:
import ResizeObserver from 'resize-observer-polyfill'
if (!window.ResizeObserver)
window.ResizeObserver = ResizeObserver
Petyo Ivanov @petyosi.
To run the tests, use npm run test
.
An end-to-end browser-based test suite is runnable with npm run e2e
, with the pages being e2e/*.tsx
and the tests e2e/*.test.ts
.
A convenient way to debug something is to preview the test cases in the browser.
To do that, run npm run dev
- it will launch a Ladle server that lets you browse the components in the examples
folder.
MIT License.
FAQs
Unknown package
The npm package react-virtuoso receives a total of 636,013 weekly downloads. As such, react-virtuoso popularity was classified as popular.
We found that react-virtuoso demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.